// 对业务接口进行统一的管理
import {
	fetch
} from "./fetch.js";

// 对首页数据的请求
export const ApiGetHomeData = function() {
	return fetch('/index/index', {}, {}, 'GET');
}

// 登录接口
export const ApiLogin = (username, pwd) => fetch('/auth/loginByWeb', {
	username: username,
	pwd: pwd,
}, {})

// 分类请求
export const Apiclassify = function() {
	return fetch('/catalog/index', {}, {}, 'GET');
}


export const Apiclassify11 = (id) => {
	return fetch('/catalog/current', {
		id: id
	}, {}, 'GET');
}

//专题数据请求
export const APITopicList = (page, size) => fetch('/topic/list', {
	page: 1,
	size: 20
}, {}, 'GET')

// 搜索窗口数据
export const searchData = () => {
	return fetch('/search/index', {}, {}, 'GET');
}
// 清除历史搜索
export const clearhistory = () => {
	return fetch('/search/clearhistory', {}, {});
}
// 实时搜索
export const helper = (keyword) => {
	return fetch('/search/helper', {
		keyword
	}, {}, "GET");
}
// 商品搜索

export const listData = (obj) => {
	return fetch('/goods/list', obj, {}, "GET");
}
// 查看购物车  /cart/index
export const ApiCart=(token)=>fetch('/cart/index',{},{
	'X-Nideshop-Token':token
},"GET")

// 切换商品选中状态  baseurl/cart/checked
export const ApiCartCheck = (isChecked, productIds) => fetch('/cart/checked', {
	isChecked, productIds:`${productIds}`
}, {},"POST")


// /cart/update  商品步进器
export const ApiUpdate= (goodsId,id,number,productId)=>fetch('/cart/update',{goodsId,id,number,productId},{},"POST")


// /cart/delete   删除商品
export const ApiDelete=(productIds)=>fetch('/cart/delete',{productIds:`${productIds}`},{},"POST")


// 首页产品明细的请求
export const ApiGetGoodsDetail = function(id) {
	return fetch('/goods/detail', {
		id
	}, {}, 'GET');
}
//首页相关产品请求
export const ApiGetGoodsRealted = function(id) {
	return fetch('/goods/related', {
		id
	}, {}, 'GET');
}


// /cart/add   加入购物车	 

export const ApiAddCart=(goodsId,productId,number)=>fetch('/cart/add',{goodsId,productId,number},{},"POST")